<template>
  <el-row :gutter="10" class="home">
    <div>
      <el-card shadow="hover">
        <el-carousel :interval="4000" type="card" height="200px">
          <el-carousel-item v-for="item in 4" :key="item">
            <h2 class="medium">走马灯{{ item }}</h2>
          </el-carousel-item>
        </el-carousel>
      </el-card>
    </div>
    <el-col :span="12">
      <div class="show">
        <el-card shadow="hover"
          ><LineEC
            :chartData="echartData.registry"
            :isAxisChart="false"
            style="height:480px;"
          ></LineEC>
        </el-card>
      </div>
    </el-col>
    <el-col :span="12">
      <div class="show">
        <el-card shadow="hover"> </el-card>
      </div>
    </el-col>
  </el-row>
</template>

<script>
import LineEC from "@/layout/echarts/LineEC.vue";
export default {
  components: { LineEC },
  data() {
    return {
      echartData: {
        registry: {
          series: []
        }
      },
      defaultProps: {
        children: "children",
        label: "label"
      }
    };
  },
  methods: {
    getPieData() {
      this.$http
        .get("http://localhost:9527/shop")
        .then(res => {
          res = res.data;
          console.log(res.data);
          this.echartData.registry.series.push({
            name: "注册用户",
            data: res.data.userData,
            type: "pie",
            radius: ["40%", "70%"],
            avoidLabelOverlap: false,
            label: {
              show: false,
              position: "center"
            },
            emphasis: {
              label: {
                show: true,
                fontSize: "30",
                fontWeight: "bold"
              }
            },
            labelLine: {
              show: false
            }
          });
        })
        .catch(err => {
          console.log(err);
        });
    },
    handleClick(data) {
      console.log(data);
    }
  },
  created() {
    this.getPieData();
  }
};
</script>

<style scoped lang="scss">
@import "~@/styles/index.scss";
</style>
